package 笔试.腾讯;

/**
 * @author:谢君臣
 * @Date:2021/8/23-19:04
 * @version:1.0
 * @function:
 */
public class Main0601 {
    public static void main(String[] args) {

    }
    public static int Secret(String s) {
        char[] sec = s.toCharArray();
        int equ = 0, ans = 0;
        // int equ1=0;
        int[] num = new int[4];

        for (int i = 0; i < sec.length; i++) {
            if ('A' <= sec[i] && sec[i] <= 'Z') num[0]++;
            else if ('a' <= sec[i] && sec[i] <= 'z') num[1]++;
            else if ('1' <= sec[i] && sec[i] <= '9') num[2]++;
            else if (sec[i] == ',' || sec[i] == '.' || sec[i] == '!' || sec[i] == '?' || sec[i] == ';') num[3]++;
            if (i != sec.length - 1 && sec[i] == sec[i + 1]) equ++; //重复字符个数
            // if (i != sec.length - 1 && i != 0 && sec[i] == sec[i + 1] && sec[i] == sec[i - 1]) equ1++;
        }
        for (int i = 0; i < num.length; i++) {
            if (num[i] != 0) ans++;
        }
        ans = 4 - ans;//不成立的条件个数
        int len = 0;
        int res = 0;
        equ = equ / 2;
        if (ans > equ) ans -= equ;
        len = sec.length + ans - equ;
        if (6 <= len && len <= 20) res = Math.max(ans, equ);
        else if (len < 6) res = Math.max(ans, equ) + 6 - len;
        else if (len > 20) res = Math.max(ans, equ) + len - 20;
        return res;
    }
}
